//
//  EFNoDataView.m
//  EFHealth
//
//  Created by nf on 16/9/14.
//  Copyright © 2016年 ef. All rights reserved.
//

#import "EFNoDataView.h"

@interface EFNoDataView()

@property (nonatomic,assign)id<noDataPortocol> Delegate ;

@property (nonatomic,strong)UILabel *titleLabel ;
@property (nonatomic,strong)UIImageView *iconImageView ;//0,没有数据，1，没有网络
@end

@implementation EFNoDataView

+ (instancetype)noNetViewWithDelegate:(id<noDataPortocol>)Delegate
{
    EFNoDataView *nodata = [[self alloc]init];
    nodata.titleLabel.text = @"加载失败，点击刷新!" ;
    nodata.iconImageView.image = [UIImage imageNamed:@"no_net.png"];
    nodata.iconImageView.width = 110 ;
    [nodata addTapCallBack:nodata sel:@selector(noNetTap)];
    nodata.Delegate = Delegate ;

    return nodata ;
}

+ (instancetype)noDataWithTitle:(NSString *)title
{
    EFNoDataView *noNet = [[self alloc]init];
    noNet.titleLabel.text = title ;
    noNet.iconImageView.image = [UIImage imageNamed:@"no_data.png"];

    return noNet ;
}

+ (instancetype)noDataWithHimg:(NSString *)himg title:(NSString *)title{
    
    EFNoDataView *noData = [[self alloc]init];
    noData.titleLabel.text = title ;
    noData.iconImageView.image = [UIImage imageNamed:himg];
    
    return noData ;
}

- (void)showInView:(UIView *)superView
{
    self.center = superView.center ;
    [superView addSubview:self];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:CGRectMake(0, 0, 200, 140)]) {
//        self.backgroundColor = [UIColor orangeColor];
    }
    return self ;
}

- (UIImageView *)iconImageView
{
    if (nil == _iconImageView) {
        _iconImageView = [[UIImageView alloc ]initWithFrame:CGRectMake(50, 0, 100, 80)];
        [self addSubview:_iconImageView];
//        _iconImageView.backgroundColor = [UIColor redColor];
    }
    return _iconImageView ;
}
- (UILabel *)titleLabel
{
    if (nil == _titleLabel) {
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 90, 200, 50)];
        _titleLabel.textAlignment = NSTextAlignmentCenter ;
        _titleLabel.textColor = kTitleColor_midden ;
        _titleLabel.font = kFontBig ;
        _titleLabel.numberOfLines = 0 ;
        [self addSubview:_titleLabel];
//        _titleLabel.backgroundColor = [UIColor blueColor];
    }
    return _titleLabel ;
}

- (void)noNetTap
{
    if (_Delegate && [_Delegate respondsToSelector:@selector(noNetViewTap)]) {
        [_Delegate noNetViewTap];
    }
}

@end

















